from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from smtplib import SMTP

class sendEmail:

    username = 'm18628904684@163.com'
    to = '1049661367@qq.com'
    password = 'QX6KiAaXy3duT3zD'
    smtpserver = 'smtp.163.com'

    def __init__(self):
        self.email_obj = MIMEMultipart('related') 

    def make_a_email(self,content_path):
        fujian = MIMEText(open(content_path,'rb').read(),'plain','urf-8')
        self.email_obj.attach(fujian)

        # 这个就是邮件展示界面里面的发件人
        self.email_obj['from'] = '这个来治愈来拿'

        # 这个是邮件展示界面里面的收件人，可以填任意内容，比如说：收件人的别名等等
        self.email_obj['to'] = self.to

        # 这个就是邮件的主题
        self.email_obj['subject'] = '事例'
        
    def send_email(self):
        smtp_obj = SMTP()
        smtp_obj.connect(self.smtpserver)
        smtp_obj.login(self.username,self.password)
        smtp_obj.sendmail(self.username,self.to,self.email_obj.as_string())
        smtp_obj.quit()
       

s = sendEmail()
s.make_a_email('/Users/show/PythonAndQA(code)/python-study2025/6_requests/project/bysms/report.html')
# s.send_email()